
public class MissingParentheses {

	public int countCorrections(String par) {
		int res = 0;
		int cnt = 0;
		for (char c: par.toCharArray()) {
			if (c == '(') {
				cnt ++;
			} else {
				if (cnt == 0) {
					res++;
				} else {
					cnt --;
				}
			}
		}
		return res + cnt;
	}
}
